﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

public partial class MenuTop_TopMenu : System.Web.UI.UserControl
{
    clsBSDungChung c = new clsBSDungChung();
    protected void Page_Load(object sender, EventArgs e)
    {
        lblMenu.Text = Menu();
    }

    protected string Menu() {
        StringBuilder buider = new StringBuilder();
        DataTable tbTop = new DataTable();
        tbTop = c.GetDataTableSQL("SELECT * FROM NhanHieu where ID in(select nhanHieuID from sanpham WHERE (Xoa = 0) group by NhanHieuID) and Xoa=0 ", "DM");
       
        buider.Append("<ul class=\"sf-menu\"> ");
        buider.Append("<li class=\"current\"> ");
        buider.Append("<a href=\"Default.aspx\">Trang chủ</a></li>");

        for (int i = 0; i < tbTop.Rows.Count; i++)
        {
           DataTable tb = new DataTable();
           tb = c.GetDataTableSQL("SELECT * FROM [Loai] as l where ID in(select LoaiID from sanpham where sanpham.loaiid=l.id and sanpham.nhanhieuid="+tbTop.Rows[i]["ID"] +" group by LoaiID) and Xoa=0 order by SapXep ASC ", "Loai");
       
            buider.Append("<li> ");
            buider.Append("<a href=\"Product.aspx?category=" + tbTop.Rows[i]["ID"] + "\">" + tbTop.Rows[i]["Ten"] + "</a>");
            buider.Append("<ul>");
            for (int j = 0; j < tb.Rows.Count; j++)
            {
                buider.Append("<li>");
                buider.Append("<a href=\"Product.aspx?cate=" + tb.Rows[j]["ID"] + "\">" + tb.Rows[j]["TenLoai"] + "</a>");
                buider.Append("</li>");
            }
            buider.Append("</ul>");
            buider.Append("</li> ");
        }
           
       
        buider.Append("<li> ");
        buider.Append("<a href=\"ProductNew.aspx\">Hàng mới về</a></li>");
        buider.Append("<li > ");
        buider.Append("<a href=\"ProductSale.aspx\">Sale of</a></li>");
        buider.Append("</ul>");
        return buider.ToString();
    }
}